import { IQueryParams } from './queryParams'
import { IPagination } from './pagination'
import { IAamsItem } from '@shared/components/aams-select/aams-select.interface'
import { ERoleType, EMenuType } from '@shared/enums'

enum EStatus {
  Normal = 'normal',
  Freeze = 'freeze',
}

export class Role {
  id: string
  roleDesc: string
  roleId: number
  roleName: string
  roleType: number
  status: EStatus
  menus: IMenu[]
  insCodes: string[]
  creatorId?: string
  creatorName?: string
}

export interface IMenu {
  ordinal?: number
  level?: number // 菜单级别
  menuId: number
  menuName: string
  menuStatus: EMenuType
  menuUri: string
  menuIcon?: string
  menuDesc?: string
  menuState?: string // 菜单 State，对应到 AngularJS 的路由名称
}

export interface IMenuOrdinal {
  menuId: number
  level: number // 菜单级别
  ordinal: number
}

export interface IRoleUpdate {
  roleName: string
  roleType: number
  roleDesc: string
  insCodes: string[]
  menus?: number[]
}

export interface IRoleQueryParams extends IQueryParams {
  roleId?: number
  roleName?: string
  status?: string
  insCode?: string
  roleType?: number
}

export interface IRolePagination extends IPagination {
  data: Role[]
}

export interface IRoleCreateFormData {
  roleName?: string
  insCode?: IAamsItem
  roleType?: ERoleType
  roleDesc?: string
  functions?: number[]
}

export const roleLevelMap = {
  1: 'ROLE_LEVEL.ADMIN',
  2: 'ROLE_LEVEL.INSTITUTION',
  3: 'ROLE_LEVEL.AGENT',
  4: 'ROLE_LEVEL.MERCHANT',
  5: 'ROLE_LEVEL.STORE',
}
